<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018-08-08
 * Time: 15:01
 */

namespace App\Http\Middleware;

use Closure;
class Tasktoken
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        if (!$request->input('tasktoken')) {
            return response()->json(['code'=>401,'msg'=>'missing tasktoken ']);
        }

        if ($request->input('tasktoken') != env('TASKTOKEN')) {
            return response()->json(['code'=>401,'msg'=>'tasktoken is error']);
        }
        return $next($request);
    }
}